﻿using System;
using System.Data;
using System.Collections.Generic;
using SERP.DAO;
namespace SERP.Controllers{
public class PersonHistoryControllerBase : Controller{
	public PersonHistoryControllerBase()
		: base()
	{
	}
	private static PersonHistoryDAO _Service; 
	public static PersonHistoryDAO Service{
		get{
			if(_Service==null)
				_Service = new PersonHistoryDAO();
			return _Service;
		}
		set{
			_Service = value;
		}
	}
    //Copy data from data row in grid to object
    public PersonHistoryEntity MapDataRowToObject(DataRow row){
		PersonHistoryEntity o = new PersonHistoryEntity();
		 if(!row.IsNull("Position"))
			o.Position=ConvertInt(row["Position"]);
		 if(!row.IsNull("StartDate"))
			o.StartDate=ConvertDateTime(row["StartDate"]);
		 if(!row.IsNull("EndDate"))
			o.EndDate=ConvertDateTime(row["EndDate"]);
		 if(!row.IsNull("OrganizationId"))
			o.OrganizationId=(Int32)(row["OrganizationId"]);
		 if(!row.IsNull("EmployeeId"))
			o.EmployeeId=(Int32)(row["EmployeeId"]);
		 if(!row.IsNull("EmployeeHistoryId"))
		    o.EmployeeHistoryId=(Int32)(row["EmployeeHistoryId"]);
		 return o;
    }
	//Copy data from object to data row in grid    
    public void MapObjectToDataRow(PersonHistoryEntity o,DataRow row){
		row["Position"]=o.Position;
		row["StartDate"]=o.StartDate;
		row["EndDate"]=o.EndDate;
		row["OrganizationId"]=o.OrganizationId;
		row["EmployeeId"]=o.EmployeeId;
		row["EmployeeHistoryId"]=o.EmployeeHistoryId;
    }
}
}
